Skip to main content

C# - SDK

The CallSDK is designed to provide a straightforward and efficient way to implement flash call (missed call) authentication within your .NET applications. It abstracts the complexities of interacting directly with the underlying API, allowing developers to quickly and easily integrate phone number verification through missed calls. This SDK is particularly useful for scenarios requiring secure and rapid user authentication.

Installation

Install the SDK

dotnet add package betatel-sdk

Import the SDK

using Betatel.SDK;

Initialization

Create an instance of the CallSDK:

string apiKey = "YOUR_API_KEY"; // Replace with your API key
CallSdk callSdk = new CallSdk(apiKey);

Replace YOUR_API_KEY with the actual value provided by your service.

warning

Security Notice:

Keep your API key secure. Do not expose it in client-side code or commit it to version control. Store it securely and retrieve it from a safe source.

Usage: Initiating a Flash Call

Use the flash method:

async Task InitiateFlashCall(string callee, string caller, int maxRingTime = 5)
{
try
{
bool success = await callSdk.FlashAsync(callee, caller, maxRingTime);

if (success)
{
Console.WriteLine("Flash call initiated successfully!");
}
else
{
Console.WriteLine("Flash call initiation failed.");
}
}
catch (Exception ex)
{
Console.WriteLine($"Error initiating flash call: {ex.Message}");
}
}

// Example usage:
await InitiateFlashCall("+15551234567", "+15559876543", 7); // Example phone numbers and maxRingTime
await InitiateFlashCall("+15551234567", "+15559876543"); // Example without optional maxRingTime
tip

Phone Number Formatting:

Ensure that the phone numbers you provide are in the E.164 format (e.g., +15551234567) or the format expected by your API. Consult your API documentation for specifics.

ParameterTypeDescription
calleestringThe phone number of the person to be called.
callerstringThe phone number of the person making the call.
maxRingTimeint(Optional) The maximum time (in seconds) to ring before the call is considered failed.

Error Handling:

The FlashAsync method will throw an Exception if the API call fails or returns a non-success status code. Wrap your FlashAsync call within a try...catch block to handle these errors gracefully.

Example of complete integration

using Betatel.SDK;

string apiKey = "YOUR_API_KEY_HERE"; // Replace with your API key
CallSdk callSdk = new CallSdk(apiKey);

async Task InitiateFlashCall(string callee, string caller, int maxRingTime = 5)
{
try
{
bool success = await callSdk.FlashAsync(callee, caller, maxRingTime);

if (success)
{
Console.WriteLine("Flash call initiated successfully!");
}
else
{
Console.WriteLine("Flash call initiation failed.");
}
}
catch (Exception ex)
{
Console.WriteLine($"Error initiating flash call: {ex.Message}");
}
}

await InitiateFlashCall("+15551234567", "+15559876543");
note

Important notes

  • Ensure that the phone numbers are in the correct format expected by your API.
  • Consult your API documentation for any specific requirements or limitations.
  • Keep your API key secure and do not expose it in client-side code.